#!/bin/bash

set -ev # Ref https://docs.travis-ci.com/user/customizing-the-build/#Implementing-Complex-Build-Steps

case "${1:?}" in
    before_install)
        git submodule update --init --recursive
        docker pull cdbattags/openresty-testsuite:latest
        ;;
    script)
        docker run \
               -i \
               --rm \
               --entrypoint=/bin/sh \
               -v "$(pwd)":/lua-resty-jwt \
               -w /lua-resty-jwt \
               --name lua-resty-jwt-tests \
               cdbattags/openresty-testsuite:latest \
               -c 'luarocks make lua-resty-jwt-dev-0.rockspec && prove -r t'
        ;;
esac
